package com.bank.util;

/**
 * 前后端数据交互协议
 */
public class JsonData {

    /**
     * 状态码
     * 0：成功
     * 1：失败
     */
    private Integer code;

    /**
     * 信息
     */
    private String msg;

    /**
     * 数据总条数
     */
    private long count;

    /**
     * 返回数据
     */
    private Object data;

    public JsonData(Integer code, String msg, long count, Object data) {
        this.code = code;
        this.msg = msg;
        this.count = count;
        this.data = data;
    }

    public JsonData(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public JsonData(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public long getCount() {
        return count;
    }

    public void setCount(long count) {
        this.count = count;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }


    public static JsonData buildSuccess(Integer code, String msg, long count, Object data) {
        return new JsonData(code, msg, count, data);
    }

    public static JsonData buildSuccess(Integer code, String msg, Object data) {
        return new JsonData(code, msg, data);
    }

    public static JsonData buildSuccess(Integer code, String msg) {
        return new JsonData(code, msg);
    }

    public static JsonData buildError(Integer code, String msg) {
        return new JsonData(code, msg);
    }

}


